import sys

from IPython.core import ultratb


class ExceptionHook:
    inst = None

    def __call__(self, *args, **kwargs):
        if self.inst is None:
            self.inst = ultratb.FormattedTB(
                mode='Plain',
                color_scheme='Neutral',
                call_pdb=1
                )
        return self.inst(*args, **kwargs)


sys.excepthook = ExceptionHook()
